package com.qlslylq.ad.sdk.rx.event;

import android.text.TextUtils;

import java.util.List;

/**
 * 消息<br/>
 */
public class BaseEvent<T> {

    private String key;

    public T data;

    public List<T> dataList;

    public BaseEvent(String key) {
        this.key = key;
    }

    public BaseEvent(String key, T data) {
        this.key = key;
        this.data = data;
    }

    public BaseEvent(String key, List<T> dataList) {
        this.key = key;
        this.dataList = dataList;
    }

    public String getKey() {
        if (TextUtils.isEmpty(key)) {
            key = "";
        }
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public boolean fromKey(String key) {
        if (TextUtils.isEmpty(key)) {
            return false;
        }
        return getKey().equals(key);
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public List<T> getDataList() {
        return dataList;
    }

    public void setDataList(List<T> dataList) {
        this.dataList = dataList;
    }
}